import request from '@/utils/request'

/**
 * 获取文章列表数据
 * @param {*} params :{channel_id, timestamp}
 * @returns
 */
export function getArticleListApi (params) {
  return request({
    url: 'articles',
    params
  })
}

/**
 * 根据文章ID添加不感兴趣
 * @param {*} target 文章ID
 * @returns
 */
export function disLikeByIdApi (target) {
  return request.post('article/dislikes', {
    target
  })
}

/**
 *
 * @param {*} target 举报文章的id
 * @param {*} type 举报类型
 * @returns
 */
export function reportByIdApi (target, type) {
  // return request.post('article/reports', {
  //   target,
  //   type
  // })
  return request({
    url: 'article/reports',
    method: 'post',
    data: {
      target,
      type
    }
  })
}

/**
 * 搜索文章
 * @param params
 * @param {*} page 页码
 * @param {*} per_page 每页条数
 * @param {*} q 搜索关键字
 */
export function searchArticleApi (params) {
  return request({
    url: 'search',
    params
  })
}

/**
 * 对文章不喜欢
 * @param {*} target 文章ID
 */
export function disLike (target) {
  return request.post('article/dislikes', {
    target
  })
}

/**
 * 取消对文章不喜欢
 * @param {*} target 文章ID
 */
export function unDisLike (target) {
  return request.delete(`article/dislikes/${target}`)
}

/**
 * 对文章点赞
 * @param {*} target 文章ID
 */
export function like (target) {
  return request.post('article/likings', {
    target
  })
}

/**
 * 取消对文章点赞
 * @param {*} target 文章ID
 */
export function unLike (target) {
  return request.delete(`article/likings/${target}`)
}
